<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) {
    static $password;
    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => $password ?: $password = bcrypt('secret'),
        'remember_token' => str_random(10),
    ];
});
//twitter fac
$factory->define(App\Twitter::class, function (Faker\Generator $faker) {
    $consumer_id = \App\Consumer::pluck("id")->toArray();
    $club_id = \App\Club::pluck("id")->toArray();
    return [
        'content' => $faker->sentence(),//获取随机名字
        'clubname' => $faker->name,
        'club_id'=>$faker->randomElement($club_id),
        'consumer_id'=>$faker->randomElement($consumer_id),
    ];
});
$factory->define(App\Twitterpic::class, function (Faker\Generator $faker) {
    $twitter_id = \App\Twitter::pluck("id")->toArray();
    return [
        'pic' => $faker->imageUrl(256,256),
        'twitter_id'=>$faker->randomElement($twitter_id),
    ];
});
$factory->define(App\Comment::class, function (Faker\Generator $faker) {
    $consumer_id = \App\Consumer::pluck("id")->toArray();
    $twitter_id = \App\Twitter::pluck("id")->toArray();
    return [
        'content' => $faker->sentence(),//获取随机名字
        'twitter_id'=>$faker->randomElement($twitter_id),
        'comment_consumer_id'=>$faker->randomElement($consumer_id),
    ];
});
$factory->define(App\Reply::class, function (Faker\Generator $faker) {
    $consumer_id = \App\Consumer::pluck("id")->toArray();
    $comment_id = \App\Comment::pluck("id")->toArray();
    return [
        'content' => $faker->sentence(),//获取随机名字
        'comment_id'=>$faker->randomElement($comment_id),
        'reply_consumer_id'=>$faker->randomElement($consumer_id),
    ];
});

// Club Factory
$factory->define(App\Club::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,//获取随机名字
        'address' => $faker->address,//获取随机地址
        'contact_tele' => $faker->phoneNumber,//获取随机电话
        'opentime' => $faker->dateTime(),//获取随机时间 但是不用填入created_at和update_at中
        'intro' => $faker->sentence(),//获取随机句子
    ];
});
// ClubBanner Factory
$factory->define(App\Clubbanner::class, function (Faker\Generator $faker) {
    $club_id = \App\Club::pluck('id')->toArray();//如果用外键 ，那么通过这句话取对应关系模型的id
    return [
        'title' => $faker->name,
        'image_url' => $faker->imageUrl(),//获取随机图片
        'club_id'=>$faker->randomElement($club_id),//吧id加入随机娃娃机，一次跳出来一个
    ];
});
// ClubVideo Factory
$factory->define(App\Clubvideo::class,function(Faker\Generator $faker){
    $club_id = \App\Club::pluck("id")->toArray();
    return[
        'title'=>$faker->name,
        'cover_image'=>$faker->imageUrl(),
        'video_url'=>$faker->imageUrl(),
        'club_id'=>$faker->randomElement($club_id),
    ];
});
//Mentors Factory
$factory->define(App\Mentor::class,function(Faker\Generator$faker){
    $club_id = \App\Club::pluck("id")->toArray();
    return[
        'name'=>$faker->name,
        'contact_address'=>$faker->address,
        'image'=>$faker->imageUrl(),
        'intro'=>$faker->sentence(),
        'club_id'=>$faker->randomElement($club_id),
    ];
});
//Clubclass Factory
$factory->define(App\Clubclass::class,function(Faker\Generator$faker) {
    $mentor_id = \App\Mentor::pluck("id")->toArray();
    return[
        'title'=>$faker->name,
        'cover_image'=>$faker->imageUrl(),
        'body'=>$faker->sentence(),
        'mentor_id'=>$faker->randomElement($mentor_id),
    ];

});
//Train Factory
$factory->define(App\Train::class,function(Faker\Generator$faker){
    $mentor_id = \App\Mentor::pluck("id")->toArray();
    $club_id = \App\Club::pluck("id")->toArray();
    return[
        'name'=>$faker->name,
        'address'=>$faker->sentence(),
        'activity_time'=>$faker->dateTime(),
        'price'=>$faker->numberBetween($min = 1000, $max = 9000),
        'contact_tele'=>$faker->phoneNumber,
        'cover_image'=>$faker->imageUrl(),
        'intro'=>$faker->sentence(),
        'attention'=>$faker->sentence(),
        'club_id'=>$faker->randomElement($club_id),
        'mentor_id'=>$faker->randomElement($mentor_id),
        'status'=>$faker->numberBetween($min = 10,$max=999),
    ];
});
//Consumer Factory
$factory->define(App\Consumer::class,function(Faker\Generator$faker){
    return[
        'nickname'=>$faker->name,
        'avatar'=>$faker->imageUrl(256,256),
        'contact_tele'=>$faker->phoneNumber,
        'sex'=>$faker->biasedNumberBetween($min=0,$max=1),
        'password'=>$faker->password(),
    ];
});
//Awardlog Factory
$factory->define(App\Awardlog::class,function(Faker\Generator$faker){
    $award_id = \App\Award::pluck("id")->toArray();
    $consumer_id = \App\Consumer::pluck("id")->toArray();
    return[
        'receiver'=>$faker->name,
        'tele'=>$faker->phoneNumber,
        'address'=>$faker->address,
        'zip_code'=>$faker->numberBetween($min = 100000,$max = 109999),
        'award_id' =>$faker->randomElement($award_id),
        'consumer_id'=>$faker->randomElement($consumer_id),
    ];
});
//Award Factory
$factory->define(App\Award::class,function(Faker\Generator$faker){
    return[
        'name'=>$faker->name,
        'award_image'=>$faker->imageUrl(),
        'integration'=>$faker->numberBetween($min = 1,$max = 9999),
        'intro'=>$faker->sentence(),
    ];
});
//Train factory
$factory->define(App\Train::class,function(Faker\Generator$faker){
    $club_id = App\Club::pluck("id")->toArray();
    $mentor_id = App\Mentor::pluck("id")->toArray();
    return[
        'name'=>$faker->name,
        'address'=>$faker->address,
        'activity_time'=>$faker->dateTime(),
        'part_count'=>$faker->numberBetween($min = 1, $max = 999),
        'price'=>$faker->numberBetween($min = 10 ,$max = 300),
        'contact_tele'=>$faker->phoneNumber,
        'cover_image'=>$faker->imageUrl(),
        'intro'=>$faker->sentence(),
        'attention'=>$faker->text(),
        'club_id'=>$faker->randomElement($club_id),
        'mentor_id'=>$faker->randomElement($mentor_id),

    ];
});
//Mentor factory
$factory->define(App\Mentor::class,function(Faker\Generator$faker){
    $club_id = \App\Club::pluck("id")->toArray();//导入外键连接
    return[
        'name'=>$faker->name,//导入姓名
        'contact_address'=>$faker->sentence,//导入地址
        'image'=>$faker->imageUrl(),//导入图片
        'intro'=>$faker->sentence(),
        'club_id'=>$faker->randomElement($club_id),//使用外键连接
    ];
});
//Activiyt factory
$factory->define(App\Activity::class,function(Faker\Generator$faker){
    return[
        'name'=>$faker->name(),
        'address'=>$faker->address,
        'activity_time'=>$faker->dateTime(),
        'part_count'=>$faker->numberBetween($min = 1, $max = 999),
        'price'=>$faker->numberBetween($min = 10 ,$max = 300),
        'contact_tele'=>$faker->phoneNumber,
        'cover_image'=>$faker->imageUrl(),
        'intro'=>$faker->sentence(),
    ];
});
//Message factory
$factory->define(App\Message::class,function(Faker\Generator$faker){
    $club_id = \App\Club::pluck("id")->toArray();//导入外键连接
    $consumer_id = \App\Consumer::pluck("id")->toArray();//导入外键连接
    return[
        "club_id"=>$faker->randomElement($club_id),
        'consumer_id'=>$faker->randomElement($consumer_id),
        'content'=>$faker->text(),
    ];
});